<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
</head>
<body>
<script type="text/javascript">
    $(function () {
        $("#submit").click(function () {
            $.ajax({
                url:"CreateTaskServlet",
                type:"post",
                data:$("form").serialize(),
                success:function (data) {
                    if(data.flag){
                        $("#alert1").css('display','block');
                        window.location.href="index.html";
                        console.log(data.msg);
                    }else{
                        $("#alert1").css('display','none');
                        $("#alert2").css('display','block');
                        console.log(data.msg);
                    }
                }
            })
        })
    })
</script>
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <div class="navbar-header">
            <!--生成汉堡按钮-->
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="index.html">Takser</a>
        </div>

        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li class="active"><a href="newTask.html">新建任务</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="about.html">关于</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="container">
    <div id="alert1" class="alert alert-success" role="alert" style="display: none">创建成功，正在转跳中...</div>
    <div id="alert2" class="alert alert-danger" role="alert" style="display: none">未登录，禁止访问</div>
    <form method="post">
        <div class="form-group">
            <label for="title">标题</label>
            <input type="text" class="form-control" id="title" name="title" placeholder="请输入任务标题">
        </div>
        <div class="form-group">
            <label for="content">内容</label>
            <input type="text" class="form-control" id="content" name="content" placeholder="请输入任务详细描述，可留空">
        </div>
        <div class="form-group">
            <label for="deadline">截止日期(留空设置为每日签到)</label>
            <input type="datetime-local" class="form-control" id="deadline" name="deadline">
        </div>
        <div class="form-group">
            <label for="createFor">目标班级(现仅支持为电信198创建任务)</label>
            <input readonly type="text" class="form-control" id="createFor" name="createFor" value="1" placeholder="现仅支持为电信198创建任务">
        </div>
        <button type="button" id="submit" class="btn btn-default">提交</button>
    </form>
</div>

</body>
</html>